from django.shortcuts import render
from django.http import HttpResponse
from .models import Article
from .models import Category

# Create your views here.
'''
def hello(request):
    return HttpResponse('欢迎使用Django')


def index(request):
    site_name = 'Django中文网'
    url = 'www.django.com'
    table = [
        '开发前的准备',
        '项目需求分析',
        '数据库设计分析',
        '创建项目',
        '基础配置',
        '欢迎页面',
        '创建数据库模型',
    ]
    dic = {
        'name': '吴秀峰',
        'qq': '445813',
        'wx': 'vipdjango',
        'email': '445813@qq.com',
        'Q群': '10218442',
    }

    all_article = Article.objects.all()

    context = {
        'site_name': site_name,
        'url': url,
        'table': table,
        'dic': dic,
        'all_article': all_article
    }

    return render(request, 'index.html', context)

'''


def index(request):
    allcategory = Category.objects.all()  # 通过Category表查出所有分类
    # 把查询出来的分类封装到上下文里
    context = {
        'allcategory': allcategory,
    }
    return render(request, 'index.html', context)  # 把上下文传到index.html页面


# 首页
# def index(request):
#    return HttpResponse('欢迎使用Django')


# 列表页
def list(request, lid):
    pass


# 内容页
def show(request, sid):
    pass


# 标签页
def tag(request, tag):
    pass


# 搜索页
def search(request):
    pass


# 关于我们
def about(request):
    pass
